

#imports
import weakref, copy
from coordinatePlane import CoordPlane
from wind import WindGenerator
from utils import Enumeration as Enum
from fal.event import EventManager

class Game(object):
    players = None
    turnNumber = None
    wind = None
    windGen = None
    phase = None
    ocean = None
    callbacks = {'addPlayer':[], 'delPlayer':[]}
    
    def __init__(self, **kwargs):
        super(Game, self).__init__(**kwargs)
        self.ocean = CoordPlane(game=self)
        self.windGen = WindGenerator()
        self.players = []
        self.phase = Game.phases.preGamePhase()
        self.turnNumber = 0
    
    ####  SERIALIZING  ####
    @classmethod
    def load(cls, file):
        pass
    
    def save(self, file):
        pass
    
    ####  PHASE-SPECIFIC  ####
    def doAction(self, action):
        """Execute an action... eventually.
        
        Takes an action as an argument, and returns validity. If valid, the 
        action is added to a set of actions to be done. The game will
        execute all actions given to it, but it might need a different
        time frame, or a specifc user input, or....
        """
        pass
    
    ####  GAME-MANAGEMENT  ####
    EventManager.registerEvent('game.players.add')
    def addPlayer(self):
        """
        Adds a new player to the current game. They start off with a
        cutter, a decent crew, a cannon, and some gold. Returns the new
        player.
        """
        pass
    
    EventManager.registerEvent('game.players.del')
    def delPlayer(self):
        """
        Deletes a player from the server/game. They will not be allowed to
        come back as themselves. They will need to start over.
        """
        pass
    
    EventManager.registerEvent('game.start')
    def startGame(self):
        """Starts the game
        
        Tells the Game object that it is time to start, and to prep
        everything accordingly. Does not actually start the first turn.
        """
        pass
    
    def sync(self, *pargs):
        """Synchronize some objects
        
        Sends objects over the network to be synchronized with all clients.
        """
    
    
    